<?php

use Illuminate\Database\Seeder;
use Illuminate\Support\Facades\DB;

class UsersTableSeeder extends Seeder
{
    /**
     * Run the database seeds.
     *
     * @return void
     */
    public function run()
    {
        //
        $users = DB::table('users')->pluck('id')->toArray();
        $users = array_values($users);
        $datas = [];

        $date = date("Y-m-d H:i:s",time());
        foreach (range(100, 200) as $index)
        {
            $datas[] = [
                'name'  => Str::random(10),
                'email' => Str::random(10).'@gmail.com',
                'password' => bcrypt('123123'),
                'email_verified_at' => $date,
                'mrp'   => 0,
                'pid'   => array_rand($users, 1),
                'mrp_code'  =>  \App\Common\Lib\MrpCode::createCode(),
            ];
            array_push($users, end($users)+1);
        }
        DB::table('users')->insert($datas);
    }
}
